/*
 * @Author: 闫聪敏
 * @Email: 
 * @Date: 2020-03-05 16:20:59
 * @Descripttion: 
 */
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { ApplyWareService } from '../apply-ware.service';
import { SubmaterialManageService } from 'src/app/material-manage/basedata-manage/submaterial-manage/submaterial-manage.service';
@Component({
  selector: 'app-apply-ware-outofstock-detail',
  templateUrl: './apply-ware-outofstock-detail.component.html',
  styleUrls: ['./apply-ware-outofstock-detail.component.scss']
})
export class ApplyWareOutofstockDetailComponent implements OnInit {

  constructor(private router: Router,
    private applyWareService: ApplyWareService,
    private activeRouter: ActivatedRoute,
    private submaterialManageService: SubmaterialManageService
  ) { }

  ngOnInit() {
    let infoId = this.activeRouter.snapshot.paramMap.get('id');
    this.GetModel(infoId);
    this.GetPickingType();
  }
  /**
   * @Author: 闫聪敏
   * @Email: 
   * @Date: 2020-03-09 17:13:11
   * @Descripttion:  获取详情
   * @Return: 
   */
  viewModel = {};
  private GetModel(id) {
    let data = {
      id: id
    }
    this.applyWareService.GetModel(data).subscribe(res => {
      res.details.forEach(item=>{item.pickTypeName = this.GetPickingTypeList.filter(e => e.value == item.pickType)[0].label;});
      this.viewModel = res;
    });
  }
  /**
   * @Author: 闫聪敏
   * @Email: 
   * @Date: 2020-03-09 17:13:06
   * @Descripttion: 返回
   * @Return: 
   */
  Return() {
    history.go(-1);
    //this.router.navigate(['/material/warehouse/applyware']);
  }
  /**
     * @Author: 闫聪敏
     * @Email: 
     * @Date: 2020-03-09 10:05:29
     * @Descripttion: 获取挑库类型
     * @Return: 
     */
  GetPickingTypeList = [];
  async GetPickingType() {
    let list: any = await this.submaterialManageService.getclTypeList('picking_type');
    this.GetPickingTypeList = list.content
  }
}
